package com.systop.dxjj.modules.student.mapper;

import com.systop.dxjj.common.pojo.Student;
import com.systop.dxjj.common.pojo.Teacher;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StudentMapper {
    /**
     * 查询所有学员信息
     */
    @Select("select * from student")
    List<Student> selectAllStudents();

    /**
     * 学员登录
     */
    @Select("select studentphone,studentpassword from student where studentphone=#{studentphone} and studentpassword=#{studentpassword}")
    Student loginStudent(Student student);

    /**
     * 根据id查询学员信息
     */
    @Select("select * from student where studentid=#{studentid}")
    Student selectStudentById(Integer id);

    /**
     * 根据姓名查询学员姓名
     */
    @Select("select * from student where studentname=#{studentname}")
    Student selectStudentByName(String name);

    /**
     * 模糊查询
     */
    @Select("select * from student where studentname like CONCAT('%', #{studentname}, '%')")
    List<Student> selectStudentByVagueName(String name);

    /**
     *插入学员信息
     */
    @Insert("insert into student(studentname,age,studentsex,studentphone,studentpassword,address,studentgrade) values (#{studentname},#{age},#{studentsex},#{studentphone},#{studentpassword},#{address},#{studentgrade})")
    int insertStudent(Student student);

    /**
     *删除学员信息
     */
    @Delete("delete from student where studentid=#{studentid}")
    int deleteStudent(Integer id);

    /**
     *更新学员信息
     */
    @Update("update student set studentname=#{studentname},age=#{age},studentsex=#{studentsex},studentphone=#{studentphone},studentpassword=#{studentpassword},address=#{address},studentgrade=#{studentgrade} where studentid=#{studentid}")
    int updateStudent(Student student);

    @Select("select * from student where studentphone=#{studentphone}")
    Student selectByPhone(String studentphone);
}
